<template>
    <el-card shadow="always" :body-style="{ padding: '20px' }">
        <template #header>
            <div class="card-header">
                <span>新商品添加</span>
            </div>
        </template>
        <!-- 
            https://www.npmjs.com/package/quill-editor-vue
            https://www.kancloud.cn/liuwave/quill/1409377
            https://quilljs.com/docs/quickstart/
         -->
        <!-- 
            1. 安装 npm install quill quill-editor-vue -S
            2. 导入 import { QuillEditor } from 'quill-editor-vue'
                ==> 选项式  需要完成 components 注册
                ==> 组合式 导入即为注册
            4. 组件加载和使用
          -->
        <QuillEditor placeholder="请输入商品详情" :options="quillEdit" />
    </el-card>
</template>

<script setup>
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import 'quill/dist/quill.bubble.css';

import { QuillEditor } from 'quill-editor-vue'
const quillEdit = {
    // quill 的完整配置定义
    modules: {
        toolbar: [
            ['bold', 'italic', 'underline', 'strike'],        // toggled buttons
            ['blockquote', 'code-block'],

            [{ 'header': 1 }, { 'header': 2 }],               // custom button values
            [{ 'list': 'ordered' }, { 'list': 'bullet' }],
            [{ 'script': 'sub' }, { 'script': 'super' }],      // superscript/subscript
            [{ 'indent': '-1' }, { 'indent': '+1' }],          // outdent/indent
            [{ 'direction': 'rtl' }],                         // text direction

            [{ 'size': ['small', false, 'large', 'huge'] }],  // custom dropdown
            [{ 'header': [1, 2, 3, 4, 5, 6, false] }],

            [{ 'color': [] }, { 'background': [] }],          // dropdown with defaults from theme
            [{ 'font': [] }],
            [{ 'align': [] }],

            ['image','video']
        ]
    },
    theme: 'snow'
}

</script>

<style lang="scss" scoped>
.el-card {
    display: flex;
    flex-flow: column;

    :deep(.el-card__body) {
        box-sizing: border-box;
        display: flex;
        flex-flow: column nowrap;
        height: 100%;
        overflow: hidden;
    }
    :deep(.ql-container){
        flex-grow: 1;
        overflow: hidden;
    }
}

</style>